<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="layui/layui.js" type="text/javascript" charset="UTF-8"></script>
<link href="layui/css/layui.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.8.2.js" charset="UTF-8"></script>
<title>Insert title here</title>
</head>
<body>

<form class="layui-form" >
<div class="layui-form-item">
  <label class="layui-form-label">电话</label>
  <div class="layui-input-block">
    <input type="text" name="dianhua" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
  </div>
</div>
<div class="layui-form-item">
  <label class="layui-form-label">邮箱</label>
  <div class="layui-input-block">
    <input type="text" name="youxiang" required  lay-verify="required" placeholder="请输入性别" autocomplete="off" class="layui-input">
  </div>
</div>


  <div class="layui-form-item">
  <label class="layui-form-label">地址</label>
  <div class="layui-input-block">
    <input type="text" name="dizhi" required  lay-verify="required" placeholder="请输入年龄" autocomplete="off" class="layui-input">
  </div>
</div>
  <div class="layui-form-item">
  <label class="layui-form-label">简介</label>
  <div class="layui-input-block">
    <input type="text" name="jianjie" required  lay-verify="required" placeholder="请输入职位" autocomplete="off" class="layui-input">
  </div>
</div>
 s
  
<div class="layui-form-item">
  <div class="layui-input-block">
    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  </div>
  </form>
  <script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //执行一个laydate实例
  laydate.render({
    elem: '#test1' //指定元素
  });
});
layui.use('form', function(){
	var form = layui.form;

	//监听提交
	 
	  
	  form.on('submit(formDemo)', function(data){
		  console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
		  console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
		  console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
		  
		  $.ajax({
				url:"Gstjservlet",//地址
				type:"get",//请求的方式
				data: data.field,
				success: function(res){//成功以后的回调函数
					
					if(res==1){
						alert("成功");
					}else{
						alert("失败");
					}
				}

			});
		  
		  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
	});
</script>



</body>
</html>